package main;

import java.net.*;
import java.io.*;

public class SimpleThread extends Thread {

    private ServerSocket socket = null;

    public SimpleThread(ServerSocket socket) {
        super("SimpleThread");
        this.socket = socket;
    }

    public void run() {

        try {
        	while(true){
        		Socket sock = socket.accept();
        		PrintWriter out = new PrintWriter(sock.getOutputStream(), true);
        		BufferedReader in = new BufferedReader(new InputStreamReader(sock
                    .getInputStream()));

        		String inputLine, outputLine;
           
	            while ((inputLine = in.readLine()) != null) {
	                outputLine = "RTT";
	                out.println(outputLine);
	
	                if (inputLine.equals("RTT OK")) {
	                    break;
	                }
	
	            }
        	}
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

